package com.trainingcloud.ctrl;


import com.trainingcloud.mapper.TaskWithStudentMapper;
import com.trainingcloud.pojo.TaskWithStudent;
import com.trainingcloud.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 组员任务表 前端控制器
 * </p>
 *
 * @author 纸鹤
 * @since 2022-10-11
 */
@RestController
public class TaskWithStudentController {

    @Autowired
    private TaskWithStudentMapper studentMapper;

    @RequestMapping("/getStudentTask")
    public ResultUtil getStudentTask(int id){
        List<TaskWithStudent> students = studentMapper.getStudentByTaskId(id);
        ResultUtil resultUtil = ResultUtil.ok();
        resultUtil.setData(students);
        return  resultUtil;
    }

    @RequestMapping("/changeScore")
    public ResultUtil changeScore(TaskWithStudent student){
        System.out.println(student);
        ResultUtil resultUtil = ResultUtil.ok();
        studentMapper.updateById(student);
        resultUtil.setData("students");
        return  resultUtil;
    }
}
